package util;

/**
 * Created by shuowu on 2018/1/12.
 */
public class PrintArray {

    public static final int MODE_NO_SPACES = 0;
    public static final int MODE_NORMAL = 1;

    public static void printArray(int[] array, int mode) {
        if (array == null) {
            System.err.println("the array is null");
            return;
        }
        if (mode == MODE_NORMAL) {
            printArray(array);
        } else {
            if(array.length <= 0) {
                return;
            }
            System.out.print(array[0]);
            for (int i = 1; i < array.length; i++) {
                System.out.print(" " + array[i]);
            }
            System.out.println();
        }
    }

    public static void printArray(int[] array) {
        if(array == null) {
            System.err.println("the array is null");
            return;
        }
        for (int i = 0; i < array.length; i++) {
            System.out.print(" " + array[i]);
        }
        System.out.println();
    }

    public static void printArray(int[][] array) {
        if(array == null) {
            System.err.println("the array is null");
            return;
        }
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(" " + array[i][j]);
            }
            System.out.println();
        }
        System.out.println();
    }
}
